package cn.luischen.service.site.impl;

import org.springframework.cache.annotation.Cacheable;
import java.util.Date;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import cn.luischen.dto.StatisticsDto;
import cn.luischen.dao.AttAchDao;
import cn.luischen.dto.ArchiveDto;
import cn.luischen.service.site.SiteService;
import cn.luischen.dto.cond.CommentCond;
import cn.luischen.model.CommentDomain;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.luischen.dto.cond.ContentCond;
import cn.luischen.model.ContentDomain;
import cn.luischen.constant.Types;
import cn.luischen.dao.ContentDao;
import org.springframework.stereotype.Service;
import cn.luischen.utils.DateKit;
import cn.luischen.dao.CommentDao;
import cn.luischen.dao.MetaDao;
import org.slf4j.Logger;
import cn.luischen.exception.BusinessException;
import cn.luischen.constant.ErrorConstant;
import cn.luischen.dto.MetaDto;
import cn.luischen.constant.WebConst;

import static org.junit.Assert.fail;
import org.mockito.MockitoAnnotations;
import java.util.Map;
import org.junit.After;
import java.lang.reflect.Method;
import static org.junit.Assert.*;
import java.util.List;
import com.alibaba.fastjson.TypeReference;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import org.powermock.reflect.Whitebox;
import org.mockito.Mock;
import org.junit.runner.RunWith;
import java.util.HashMap;
import java.util.ArrayList;
import com.alibaba.fastjson.JSONArray;
import org.powermock.core.classloader.annotations.PrepareForTest;
import static org.junit.Assert.assertEquals;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.junit.Test;
import com.unitspirit.runtime.*;
import org.mockito.Mockito;
import com.alibaba.fastjson.JSON;
import org.junit.Rule;
import static org.junit.Assert.assertTrue;
import com.alibaba.fastjson.parser.ParserConfig;

/**
* The class <code>SiteServiceImplTest</code> contains tests for the class <code>{@link SiteServiceImpl}</code>.
* Copyright (c) 2020
* 
* @generatedBy UnitSpirit at 2021-09-07 17:52:05
* @version 1.0.20210903
*/

@PowerMockIgnore({ "javax.management.*" })
@RunWith(PowerMockRunner.class)
@PrepareForTest({ cn.luischen.dto.cond.ContentCond.class, cn.luischen.dao.ContentDao.class })
public class SiteServiceImpl_getNewArticles_WGTest {

	@InjectMocks
	cn.luischen.service.site.impl.SiteServiceImpl unitspirit_fixture;
	@Mock
	cn.luischen.dao.ContentDao mock_ContentDao;
	@Mock
	cn.luischen.dao.MetaDao mock_MetaDao;
	@Mock
	cn.luischen.dao.AttAchDao mock_AttAchDao;
	@Mock
	cn.luischen.dao.CommentDao mock_CommentDao;

	@Rule
	public ExpectedException unitspirit_thrown = ExpectedException.none();

	/**
	* 测试方法初始化.
	* 
	* @throws Exception 
	*         if the initialization fails for some reason 
	*  
	* @generatedBy UnitSpirit at 2021-09-07 17:52:05
	*/
	@org.junit.Before
	public void setUp() throws Exception {
		try {
			GlobalUnitInit.init();
			MockitoAnnotations.initMocks(this);
			ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	/**
	* @date 2021-09-07 17:52:05
	* @see cn.luischen.service.site.impl.SiteServiceImpl#getNewArticles
	* @category auto generate by UnitSpirit  
	* @author UnitSpirit   
	*/
	@Test
	public void test_getNewArticles_0113_190013_782_2_01() throws Throwable {
		//被测函数参数定义
		int int_p_0 = 5;
		//成员变量设置

		//返回值定义 
		String result_expected = "[]";

		cn.luischen.dto.cond.ContentCond mock_sub_caller_ContentCond2 = PowerMockito
				.mock(cn.luischen.dto.cond.ContentCond.class);
		java.util.List<cn.luischen.model.ContentDomain> mock_result_Page1 = JSON.parseArray("[]",
				cn.luischen.model.ContentDomain.class);

		PowerMockito.whenNew(cn.luischen.dto.cond.ContentCond.class).withNoArguments()
				.thenReturn(mock_sub_caller_ContentCond2);
		PowerMockito.when(mock_ContentDao.getArticlesByCond(Mockito.any())).thenReturn(mock_result_Page1);

		java.util.List<cn.luischen.model.ContentDomain> unitspirit_result = unitspirit_fixture.getNewArticles(int_p_0);
		UnitAssert.assertEquals(result_expected, UnitSpiritFastJsonUtil.getJsonString2(unitspirit_result));
	}

	/**
	* @date 2021-09-07 17:52:06
	* @see cn.luischen.service.site.impl.SiteServiceImpl#getNewArticles
	* @category auto generate by UnitSpirit  
	* @author UnitSpirit   
	*/
	@Test
	public void test_getNewArticles_0113_190013_782_4_01() throws Throwable {
		//被测函数参数定义
		int int_p_0 = 5;
		//成员变量设置

		//返回值定义 
		String result_expected = "[]";

		cn.luischen.dto.cond.ContentCond mock_sub_caller_ContentCond2 = PowerMockito
				.mock(cn.luischen.dto.cond.ContentCond.class);
		java.util.List<cn.luischen.model.ContentDomain> mock_result_Page1 = JSON.parseArray("[]",
				cn.luischen.model.ContentDomain.class);

		PowerMockito.whenNew(cn.luischen.dto.cond.ContentCond.class).withNoArguments()
				.thenReturn(mock_sub_caller_ContentCond2);
		PowerMockito.when(mock_ContentDao.getArticlesByCond(Mockito.any())).thenReturn(mock_result_Page1);

		java.util.List<cn.luischen.model.ContentDomain> unitspirit_result = unitspirit_fixture.getNewArticles(int_p_0);
		UnitAssert.assertEquals(result_expected, UnitSpiritFastJsonUtil.getJsonString2(unitspirit_result));
	}

}
